<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/favicon.ico">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon.ico">
  <link rel="mask-icon" href="/images/favicon.ico" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"yoursite.com","root":"/","scheme":"Mist","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"always","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="Lint是一个静态代码质量检查工具，本文主要介绍lint工具的使用和自定义lint规则与实践">
<meta property="og:type" content="article">
<meta property="og:title" content="Android Lint工具和自定义Lint规则">
<meta property="og:url" content="http://yoursite.com/2018/12/04/android-2018-12-04-LintTools/index.html">
<meta property="og:site_name" content="Akiyama&#39;s Blog">
<meta property="og:description" content="Lint是一个静态代码质量检查工具，本文主要介绍lint工具的使用和自定义lint规则与实践">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://yoursite.com/images/Lint/lint_process.png">
<meta property="og:image" content="http://yoursite.com/images/Lint/android_inspect01.png">
<meta property="og:image" content="http://yoursite.com/images/Lint/android_inspect02.png">
<meta property="og:image" content="http://yoursite.com/images/Lint/android_inspect03.png">
<meta property="og:image" content="http://yoursite.com/images/Lint/lint_config.png">
<meta property="og:image" content="http://yoursite.com/images/Lint/lint_config01.png">
<meta property="og:image" content="http://yoursite.com/images/Lint/lint_config02.png">
<meta property="og:image" content="http://yoursite.com/images/Lint/custom_lint01.png">
<meta property="og:image" content="http://yoursite.com/images/Lint/lintchecks.png">
<meta property="article:published_time" content="2018-12-03T16:00:00.000Z">
<meta property="article:modified_time" content="2021-05-16T10:04:20.533Z">
<meta property="article:author" content="丘山月夜">
<meta property="article:tag" content="Android">
<meta property="article:tag" content="进阶">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://yoursite.com/images/Lint/lint_process.png">

<link rel="canonical" href="http://yoursite.com/2018/12/04/android-2018-12-04-LintTools/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>Android Lint工具和自定义Lint规则 | Akiyama's Blog</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">Akiyama's Blog</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">丘山月夜的博客</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="home fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="user fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="tags fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="th fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="archive fa fa-archive fa-fw"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/12/04/android-2018-12-04-LintTools/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.png">
      <meta itemprop="name" content="丘山月夜">
      <meta itemprop="description" content="君は空を見てるか,<br>風の音を聞いてるか">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Akiyama's Blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          Android Lint工具和自定义Lint规则
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2018-12-04 00:00:00" itemprop="dateCreated datePublished" datetime="2018-12-04T00:00:00+08:00">2018-12-04</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-05-16 18:04:20" itemprop="dateModified" datetime="2021-05-16T18:04:20+08:00">2021-05-16</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/" itemprop="url" rel="index"><span itemprop="name"></span></a>
                </span>
            </span>

          
            <div class="post-description">Lint是一个静态代码质量检查工具，本文主要介绍lint工具的使用和自定义lint规则与实践</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h2 id="Lint工具使用和自定义Lint"><a href="#Lint工具使用和自定义Lint" class="headerlink" title="Lint工具使用和自定义Lint"></a>Lint工具使用和自定义Lint</h2><h2 id="Lint介绍"><a href="#Lint介绍" class="headerlink" title="Lint介绍"></a>Lint介绍</h2><h3 id="Lint简介"><a href="#Lint简介" class="headerlink" title="Lint简介"></a>Lint简介</h3><p>静态代码质量检查（分析、扫描）工具</p>
<p>Android Lint 是 SDK Tools 16（ADT 16）开始引入的一个代码扫描工具（在sdk目录/tools/bin下可以找到lint工具），通过对代码进行静态分析，可以检查代码规范问题和质量问题，并提出一些改进建议。可以规范团队代码风格，提高代码质量，指导开发者正确使用sdk等。</p>
<p>原生lint规则已经很全面了，不过有时候在团队开发中我们得根据需求定制自己的lint规则</p>
<p>举例：</p>
<ul>
<li>提醒使用自己的log工具，不用原生的log</li>
<li>提醒try-catch代码块后记得加finally</li>
<li>提醒资源文件，资源id命名规范，加模块名前缀</li>
<li>……</li>
</ul>
<h3 id="lint原理"><a href="#lint原理" class="headerlink" title="lint原理"></a>lint原理</h3><p>lint规则是在AST（抽象语法树，类似dom树）上进行解析。可以将项目里的一切视为对象，如目录、文件，java类、方法，xml元素、属性、值等，针对这些对象进行分析处理，并上报问题。</p>
<ul>
<li>推荐一个Android Studio的插件：PsiViewer，可以查看语法树</li>
</ul>
<h3 id="有几种使用方式"><a href="#有几种使用方式" class="headerlink" title="有几种使用方式"></a>有几种使用方式</h3><ul>
<li>使用lint命令行执行</li>
<li>使用android studio提供的可视化工具</li>
<li>结合gradle命令，如<code>./gradlew lint</code> （推荐）</li>
</ul>
<h3 id="Lint过程"><a href="#Lint过程" class="headerlink" title="Lint过程"></a>Lint过程</h3><p><img src="/images/Lint/lint_process.png" alt="lint过程"></p>
<h2 id="Android-Lint使用"><a href="#Android-Lint使用" class="headerlink" title="Android Lint使用"></a>Android Lint使用</h2><h3 id="使用Android-Studio提供的工具运行lint"><a href="#使用Android-Studio提供的工具运行lint" class="headerlink" title="使用Android Studio提供的工具运行lint"></a>使用Android Studio提供的工具运行lint</h3><ul>
<li>在Android Studio菜单栏Analyze&gt;Inspect code，选择要扫描的范围（也可以在右键菜单中打开）<br><img src="/images/Lint/android_inspect01.png" alt="android studio lint"></li>
<li>配置检查规则：<br><img src="/images/Lint/android_inspect02.png" alt="android studio lint"></li>
<li>检查结果示例<br><img src="/images/Lint/android_inspect03.png" alt="android studio lint"></li>
</ul>
<p>除此之外，还可以通过配置lint.xml文件进行配置，参考<a target="_blank" rel="noopener" href="https://developer.android.google.cn/studio/write/lint">开发者文档</a></p>
<h3 id="推荐使用gradle命令运行lint"><a href="#推荐使用gradle命令运行lint" class="headerlink" title="推荐使用gradle命令运行lint"></a>推荐使用gradle命令运行lint</h3><ul>
<li>可以导出html、xml文件到模块下的build/reports目录下，使用浏览器打开，查看lint结果</li>
</ul>
<p><code>./gradlew -p 模块名 lint</code>或<code>./gradlew 模块名:lint</code></p>
<h3 id="配置"><a href="#配置" class="headerlink" title="配置"></a>配置</h3><h4 id="lint-xml配置"><a href="#lint-xml配置" class="headerlink" title="lint.xml配置"></a>lint.xml配置</h4><ul>
<li>官方文档说要放到项目根目录，试了一下不行，需要放到相应的module目录下</li>
<li>更新lint.xml配置有时候应用可能不及时，需要sync一下或者重启Android Studio</li>
<li>鼠标移到问题代码处，点开more，可以看到issue id</li>
</ul>
<p>举例</p>
<ul>
<li>配置规则<br><img src="/images/Lint/lint_config.png" alt="配置规则"></li>
<li>前后对比<ul>
<li>编辑器里的提示对比<br><img src="/images/Lint/lint_config01.png" alt="配置前后对比"></li>
<li>导出结果对比<br><img src="/images/Lint/lint_config02.png" alt="配置前后对比"></li>
</ul>
</li>
</ul>
<h4 id="Java代码配置"><a href="#Java代码配置" class="headerlink" title="Java代码配置"></a>Java代码配置</h4><p>添加 <code>@SuppressLint</code> 注解，禁止Lint 检查某个 Java 类或方法。<br>如：<code>@SuppressLint(&quot;all&quot;)</code> ，禁止检查所有lint问题</p>
<h4 id="xml文件配置"><a href="#xml文件配置" class="headerlink" title="xml文件配置"></a>xml文件配置</h4><ul>
<li>添加命名空间</li>
</ul>
<p><code>xmlns:tools=&quot;http://schemas.android.com/tools&quot;</code></p>
<ul>
<li>添加属性：配置禁止检查无用资源lint，该属性会继承到子元素</li>
</ul>
<p><code>tools:ignore=&quot;UnusedResources&quot;</code></p>
<h4 id="gradle配置"><a href="#gradle配置" class="headerlink" title="gradle配置"></a>gradle配置</h4><p>在构建时执行</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br></pre></td><td class="code"><pre><span class="line">android &#123; </span><br><span class="line"> lintOptions &#123;</span><br><span class="line">    &#x2F;&#x2F; true--关闭lint报告的分析进度</span><br><span class="line">    quiet true</span><br><span class="line">    &#x2F;&#x2F; true--错误发生后停止gradle构建</span><br><span class="line">    abortOnError false</span><br><span class="line">    &#x2F;&#x2F; true--只报告error</span><br><span class="line">    ignoreWarnings true</span><br><span class="line">    &#x2F;&#x2F; true--忽略有错误的文件的全&#x2F;绝对路径(默认是true)</span><br><span class="line">    absolutePaths true</span><br><span class="line">    &#x2F;&#x2F; true--检查所有问题点，包含其他默认关闭项</span><br><span class="line">    checkAllWarnings true</span><br><span class="line">    &#x2F;&#x2F; true--所有warning当做error</span><br><span class="line">    warningsAsErrors true</span><br><span class="line">    &#x2F;&#x2F; 关闭指定问题检查</span><br><span class="line">    disable &#39;TypographyFractions&#39;, &#39;TypographyQuotes&#39;</span><br><span class="line">    &#x2F;&#x2F; 打开指定问题检查</span><br><span class="line">    enable &#39;RtlHardcoded&#39;, &#39;RtlCompat&#39;, &#39;RtlEnabled&#39;</span><br><span class="line">    &#x2F;&#x2F; 仅检查指定问题 check &#39;NewApi&#39;, &#39;InlinedApi&#39;</span><br><span class="line">    &#x2F;&#x2F; true--error输出文件不包含源码行号</span><br><span class="line">    noLines true</span><br><span class="line">    &#x2F;&#x2F; true--显示错误的所有发生位置，不截取</span><br><span class="line">    showAll true</span><br><span class="line">    &#x2F;&#x2F; 回退lint设置(默认规则)</span><br><span class="line">    lintConfig file(&quot;default-lint.xml&quot;)</span><br><span class="line">    &#x2F;&#x2F; true--生成txt格式报告(默认false)</span><br><span class="line">    textReport true</span><br><span class="line">    &#x2F;&#x2F; 重定向输出；可以是文件或&#39;stdout&#39;</span><br><span class="line">    textOutput &#39;stdout&#39;</span><br><span class="line">    &#x2F;&#x2F; true--生成XML格式报告</span><br><span class="line">    xmlReport false</span><br><span class="line">    &#x2F;&#x2F; 指定xml报告文档(默认lint-results.xml)</span><br><span class="line">    xmlOutput file(&quot;lint-report.xml&quot;)</span><br><span class="line">    &#x2F;&#x2F; true--生成HTML报告(带问题解释，源码位置，等)</span><br><span class="line">    htmlReport true</span><br><span class="line">    &#x2F;&#x2F; html报告可选路径(构建器默认是lint-results.html )</span><br><span class="line">    htmlOutput file(&quot;lint-report.html&quot;)</span><br><span class="line">    &#x2F;&#x2F; true--所有正式版构建执行规则生成崩溃的lint检查，如果有崩溃问题将停止构建</span><br><span class="line">    checkReleaseBuilds true</span><br><span class="line">    &#x2F;&#x2F; 在发布版本编译时检查(即使不包含lint目标)，指定问题的规则生成崩溃</span><br><span class="line">    fatal &#39;NewApi&#39;, &#39;InlineApi&#39;</span><br><span class="line">    &#x2F;&#x2F; 指定问题的规则生成错误</span><br><span class="line">    error &#39;Wakelock&#39;, &#39;TextViewEdits&#39;</span><br><span class="line">    &#x2F;&#x2F; 指定问题的规则生成警告</span><br><span class="line">    warning &#39;ResourceAsColor&#39;</span><br><span class="line">    &#x2F;&#x2F; 忽略指定问题的规则(同关闭检查)</span><br><span class="line">    ignore &#39;TypographyQuotes&#39;</span><br><span class="line">&#125;&#125;</span><br></pre></td></tr></table></figure>

<h2 id="自定义Lint流程"><a href="#自定义Lint流程" class="headerlink" title="自定义Lint流程"></a>自定义Lint流程</h2><h4 id="自定义lint规则"><a href="#自定义lint规则" class="headerlink" title="自定义lint规则"></a>自定义lint规则</h4><ul>
<li><p>根目录<code>build.gradle</code>中添加gradle插件</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">classpath &quot;com.android.tools.build:gradle:$gradlePluginVersion&quot;</span><br></pre></td></tr></table></figure></li>
<li><p>新建一个模块，如checks，用于编写自定义lint规则</p>
</li>
<li><p>修改build.gradle如下<br><img src="/images/Lint/custom_lint01.png" alt="自定义lint规则gradle配置"></p>
<p>– 添加java plugin</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">apply plugin: &#39;java-library&#39;</span><br></pre></td></tr></table></figure>

<p>– 添加依赖，版本号根据需要填</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">compile &quot;com.android.tools.lint:lint-api:$lintVersion&quot; &#x2F;&#x2F;Lint Api</span><br><span class="line">compile &quot;com.android.tools.lint:lint-checks:$lintVersion&quot; &#x2F;&#x2F;android lint原生规则</span><br><span class="line">testCompile &quot;com.android.tools.lint:lint:$lintVersion&quot; &#x2F;&#x2F;用于运行Lint检查</span><br></pre></td></tr></table></figure>

<p>– 配置jar打包，Lint-Registry是透露给lint工具的注册类的方法，</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">jar &#123;</span><br><span class="line">    manifest &#123;</span><br><span class="line">        attributes(&quot;Lint-Registry&quot;: &quot;com.my.smart.lint.checks.MyIssueRegistry&quot;)</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></li>
<li><p>编写自定义Lint规则，下面介绍</p>
</li>
<li><p>编译生成jar，路径为<code>/checks/build/libs/checks.jar</code></p>
</li>
</ul>
<h3 id="应用lint规则"><a href="#应用lint规则" class="headerlink" title="应用lint规则"></a>应用lint规则</h3><p>有以下几种方式</p>
<ol>
<li>将jar放到~/.android/lint/下，对所有本地项目生效。  </li>
<li>将jar放到模块libs目录，使用lintChecks方式引入<br><img src="/images/Lint/lintchecks.png" alt="lintChecks解释"></li>
<li>将jar打包成aar，使用implementation引入（推荐）</li>
</ol>
<p>使用第三种方式引入</p>
<ul>
<li><p>新建一个library模块，用于打包aar </p>
</li>
<li><p>在library的dependencies中添加</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">lintChecks project(&#39;:checks&#39;)</span><br></pre></td></tr></table></figure></li>
<li><p>打包上传到maven</p>
</li>
</ul>
<h2 id="编写lint规则"><a href="#编写lint规则" class="headerlink" title="编写lint规则"></a>编写lint规则</h2><p>可以通过看<a target="_blank" rel="noopener" href="https://android.googlesource.com/platform/tools/base/+/master/lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks">已有的Lint规则源码</a>，<a target="_blank" rel="noopener" href="https://www.javadoc.io/doc/com.android.tools.lint/lint-api/25.3.0">LintApi文档</a>来学习</p>
<p>主要使用<code>lint-api</code>提供的接口进行开发</p>
<h3 id="常用api如下"><a href="#常用api如下" class="headerlink" title="常用api如下"></a>常用api如下</h3><ul>
<li>Issue：表示一个Lint规则。例如调用 Toast.makeText() 方法后，没有调用 Toast.show() 方法将其显示。</li>
<li>IssueRegistry：用于注册要检查的Issue列表。自定义Lint需要生成一个jar文件，其Manifest指向IssueRegistry类。</li>
<li>Detector：用于检测并报告代码中的Issue。每个Issue包含一个Detector。</li>
<li>Scope：声明Detector要扫描的代码范围，例如Java源文件、XML资源文件、Gradle文件等。每个Issue可包含多个Scope。</li>
<li>Scanner：用于扫描并发现代码中的Issue。每个Detector可以实现一到多个Scanner。<ul>
<li>JavaScanner（最早） / JavaPsiScanner / UastScanner（最新、推荐）：扫描Java源文件</li>
<li>XmlScanner：扫描XML文件</li>
<li>ClassScanner：扫描class文件</li>
<li>BinaryResourceScanner：扫描二进制资源文件</li>
<li>ResourceFolderScanner：扫描资源文件夹</li>
<li>GradleScanner：扫描Gradle脚本</li>
<li>OtherFileScanner：扫描其他类型文件</li>
<li>……</li>
</ul>
</li>
</ul>
<h4 id="例-检查控件id命名前缀，如ImageView以iv-开头，Button以btn开头"><a href="#例-检查控件id命名前缀，如ImageView以iv-开头，Button以btn开头" class="headerlink" title="例:检查控件id命名前缀，如ImageView以iv_开头，Button以btn开头"></a>例:检查控件id命名前缀，如ImageView以iv_开头，Button以btn开头</h4><ul>
<li>实现Detector</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//1. 继承ResourceXmlDetector，该类实现了XmlScanner，表示检查xml文件</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">TuyaResIdDetector</span> <span class="keyword">extends</span> <span class="title">ResourceXmlDetector</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> Implementation IMPLEMENTATION_RES_ONLY = <span class="keyword">new</span> Implementation(</span><br><span class="line">            TuyaResIdDetector.class,</span><br><span class="line">            Scope.RESOURCE_FILE_SCOPE);</span><br><span class="line"></span><br><span class="line">    <span class="comment">//2. 定义Issue，包括id，描述，解释，分类，优先级，严重级别，作用域</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> Issue RES_ID_ISSUE = Issue.create(</span><br><span class="line">            <span class="string">&quot;TuyaResId&quot;</span>,</span><br><span class="line">            <span class="string">&quot;Id命名不规范&quot;</span>,</span><br><span class="line">            <span class="string">&quot;Id 命名以控件缩写为前缀&quot;</span>,</span><br><span class="line">            Category.SECURITY,</span><br><span class="line">            <span class="number">5</span>,</span><br><span class="line">            Severity.ERROR,</span><br><span class="line">            IMPLEMENTATION_RES_ONLY);</span><br><span class="line"></span><br><span class="line">    <span class="comment">//3. 过滤文件夹</span></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">boolean</span> <span class="title">appliesTo</span><span class="params">(ResourceFolderType folderType)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> ResourceFolderType.LAYOUT == folderType;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">//4. 过滤tag</span></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> Collection&lt;String&gt; <span class="title">getApplicableElements</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        Collection&lt;String&gt; elements = <span class="keyword">new</span> ArrayList&lt;&gt;();</span><br><span class="line">        elements.add(LINEAR_LAYOUT);</span><br><span class="line">        elements.add(RELATIVE_LAYOUT);</span><br><span class="line">        elements.add(FRAME_LAYOUT);</span><br><span class="line">        elements.add(CONSTRAINT_LAYOUT);</span><br><span class="line">        elements.add(LIST_VIEW);</span><br><span class="line">        elements.add(SCROLL_VIEW);</span><br><span class="line">        elements.add(TEXT_VIEW);</span><br><span class="line">        elements.add(IMAGE_VIEW);</span><br><span class="line">        elements.add(CHECK_BOX);</span><br><span class="line">        elements.add(RADIO_BUTTON);</span><br><span class="line">        elements.add(EDIT_TEXT);</span><br><span class="line">        elements.add(RECYCLER_VIEW);</span><br><span class="line">        elements.add(BUTTON);</span><br><span class="line"></span><br><span class="line"><span class="comment">//        elements.add(PROGRESS_BAR);</span></span><br><span class="line"><span class="comment">//        elements.add(FQCN_DATE_PICKER);</span></span><br><span class="line"><span class="comment">//        elements.add(FQCN_TIME_PICKER);</span></span><br><span class="line"><span class="comment">//        elements.add(RADIO_GROUP);</span></span><br><span class="line"></span><br><span class="line">        <span class="keyword">return</span> elements;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">//5. 过滤属性，这里有坑，下面解释</span></span><br><span class="line"><span class="comment">//    @Override</span></span><br><span class="line"><span class="comment">//    public Collection&lt;String&gt; getApplicableAttributes() &#123;</span></span><br><span class="line"><span class="comment">//        return Collections.singletonList(&quot;id&quot;);</span></span><br><span class="line"><span class="comment">//    &#125;</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">//6. 已经定位到对象，对其进行解析，若不符合规则，则报错</span></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">visitElement</span><span class="params">(XmlContext context, Element element)</span> </span>&#123;</span><br><span class="line">        checkIdAttr(context,element);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">private</span> <span class="keyword">void</span> <span class="title">checkIdAttr</span><span class="params">(XmlContext context, Element element)</span></span>&#123;</span><br><span class="line">    <span class="comment">//7. 对象解析</span></span><br><span class="line">        Attr attributeNode = element.getAttributeNode(<span class="string">&quot;android:id&quot;</span>);</span><br><span class="line">        String tag = element.getTagName();</span><br><span class="line">        System.out.println(<span class="string">&quot;ResId Tag Name：&quot;</span> + tag);</span><br><span class="line">        <span class="keyword">if</span> (tag.equals(BUTTON)) &#123;</span><br><span class="line">            tag = <span class="string">&quot;btn&quot;</span>;</span><br><span class="line">        &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">            tag = tag.replaceAll(<span class="string">&quot;[a-z\\d.]&quot;</span>, <span class="string">&quot;&quot;</span>);</span><br><span class="line">            tag = tag.toLowerCase();</span><br><span class="line">        &#125;</span><br><span class="line">        System.out.println(<span class="string">&quot;ResId Tag Prefix：&quot;</span> + tag);</span><br><span class="line">        <span class="keyword">if</span> (attributeNode != <span class="keyword">null</span>) &#123;</span><br><span class="line">            String value = attributeNode.getValue();</span><br><span class="line">            <span class="keyword">if</span> (!value.startsWith(ANDROID_ID_PREFIX)</span><br><span class="line">                    &amp;&amp; !value.startsWith(ANDROID_NEW_ID_PREFIX)</span><br><span class="line">                    &amp;&amp; !value.startsWith(NEW_ID_PREFIX + tag)) &#123;</span><br><span class="line">                <span class="comment">//8. 报告错误，参数：Issue，Node（对象节点），Location（报错位置），Message（提示信息），LintFix（解决方案）</span></span><br><span class="line">                context.report(RES_ID_ISSUE,</span><br><span class="line">                        attributeNode,</span><br><span class="line">                        context.getLocation(attributeNode),</span><br><span class="line">                        String.format(<span class="string">&quot; id 命名以 %s_ 开头&quot;</span>, tag));</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>注：</p>
<p><code>getApplicableElements</code>和<code>visitElement</code>，<code>getApplicableAttributes </code>和<code>visitAttribute</code>是成对使用的，一开始以为是链式的，先过滤元素，再过滤元素属性，最后只要实现visitAttribute。结果发现visitElement也会被调用。实现了返回反而会多执行visit方法。</p>
<ul>
<li>注册规则</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">public class TuyaIssueRegistry extends IssueRegistry &#123;</span><br><span class="line">    @Override</span><br><span class="line">    public List&lt;Issue&gt; getIssues() &#123;</span><br><span class="line">        return Arrays.asList(</span><br><span class="line">                TuyaResIdDetector.RES_ID_ISSUE</span><br><span class="line">        );</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="名词解释"><a href="#名词解释" class="headerlink" title="名词解释"></a>名词解释</h3><ul>
<li><code>Issue</code>:Lint规则<ul>
<li><code>Id</code>: 规则标识，唯一</li>
<li><code>Description</code>: 规则描述</li>
<li><code>Explanation</code>: 规则说明，解决方案</li>
<li><code>Severity</code>: 规则严重程度，由高到低<ul>
<li>FATAL</li>
<li>ERROR</li>
<li>WARNING</li>
<li>INFORMATIONAL</li>
<li>IGNORE</li>
</ul>
</li>
<li><code>Priority</code>: 规则优先级，1-10，10最高</li>
<li><code>Category</code>: 规则分类（部分），可自定义<ul>
<li>Lint</li>
<li>Correctness (子分类 Messages):正确性</li>
<li>Security：安全性</li>
<li>Performance:性能</li>
<li>Usability (子分类 Typography, Icons):易用性</li>
<li>A11Y (Accessibility):无障碍</li>
<li>I18N (Internationalization，子分类 Rtl)：国际化</li>
</ul>
</li>
</ul>
</li>
</ul>
<h2 id="补充"><a href="#补充" class="headerlink" title="补充"></a>补充</h2><ul>
<li>由于缓存或者其他原因，有时候需要重启Android Studio才能应用自定义lint规则</li>
<li>推荐使用gradle命令执行lint</li>
<li>除了手动运行Lint外，大部分问题在编写代码时Android Studio就会给出提醒</li>
<li>自定义的规则使用Android Studio的Inspect检查不出来，不过在代码编写的时候会有提示，需要将规则放到<code>~/.android/lint/</code>目录下才会生效，建议用gradle命令运行导出Issue</li>
</ul>
<h2 id="参考文章"><a href="#参考文章" class="headerlink" title="参考文章"></a>参考文章</h2><ul>
<li><a target="_blank" rel="noopener" href="https://blog.csdn.net/u010360371/article/details/50189171">android lint check的学习和自定义以及lint语法</a></li>
<li><a target="_blank" rel="noopener" href="https://www.jianshu.com/p/cbd9a643a6b7">使用Lint</a></li>
<li><a target="_blank" rel="noopener" href="https://www.jianshu.com/p/a0f28fbef73f">Android Studio 工具：Lint 代码扫描工具（含自定义lint）</a></li>
<li><a target="_blank" rel="noopener" href="https://blog.csdn.net/ouyang_peng/article/details/80374867">【我的Android进阶之旅】Android自定义Lint实践</a></li>
<li><a target="_blank" rel="noopener" href="http://www.cnblogs.com/oneapm/p/5221072.html">自定义 Lint 规则简介</a></li>
<li><a target="_blank" rel="noopener" href="https://www.colabug.com/2109876.html">Android Lint：自定义Lint调试与开发</a></li>
</ul>

    </div>

    
    
    
        

  <div class="followme">
    <p>欢迎关注我的其它发布渠道</p>

    <div class="social-list">

        <div class="social-item">
          <a target="_blank" class="social-link" href="/images/wechat_channel.jpg">
            <span class="icon">
              <i class="fab fa-weixin"></i>
            </span>

            <span class="label">WeChat</span>
          </a>
        </div>
    </div>
  </div>


      <footer class="post-footer">
          
          <div class="post-tags">
              <a href="/" rel="tag"><i class="fa fa-tag"></i> </a>
              <a href="/" rel="tag"><i class="fa fa-tag"></i> </a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2018/11/24/android-2018-11-24-ProGuard/" rel="prev" title="安卓ProGuard混淆">
      <i class="fa fa-chevron-left"></i> 安卓ProGuard混淆
    </a></div>
      <div class="post-nav-item">
    <a href="/2018/12/11/android-2018-12-11-ADBTool/" rel="next" title="ADB工具（Android Debug Bridge）">
      ADB工具（Android Debug Bridge） <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="header-overlay"></div>
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#Lint%E5%B7%A5%E5%85%B7%E4%BD%BF%E7%94%A8%E5%92%8C%E8%87%AA%E5%AE%9A%E4%B9%89Lint"><span class="nav-number">1.</span> <span class="nav-text">Lint工具使用和自定义Lint</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Lint%E4%BB%8B%E7%BB%8D"><span class="nav-number">2.</span> <span class="nav-text">Lint介绍</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Lint%E7%AE%80%E4%BB%8B"><span class="nav-number">2.1.</span> <span class="nav-text">Lint简介</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#lint%E5%8E%9F%E7%90%86"><span class="nav-number">2.2.</span> <span class="nav-text">lint原理</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%9C%89%E5%87%A0%E7%A7%8D%E4%BD%BF%E7%94%A8%E6%96%B9%E5%BC%8F"><span class="nav-number">2.3.</span> <span class="nav-text">有几种使用方式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Lint%E8%BF%87%E7%A8%8B"><span class="nav-number">2.4.</span> <span class="nav-text">Lint过程</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Android-Lint%E4%BD%BF%E7%94%A8"><span class="nav-number">3.</span> <span class="nav-text">Android Lint使用</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E4%BD%BF%E7%94%A8Android-Studio%E6%8F%90%E4%BE%9B%E7%9A%84%E5%B7%A5%E5%85%B7%E8%BF%90%E8%A1%8Clint"><span class="nav-number">3.1.</span> <span class="nav-text">使用Android Studio提供的工具运行lint</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%8E%A8%E8%8D%90%E4%BD%BF%E7%94%A8gradle%E5%91%BD%E4%BB%A4%E8%BF%90%E8%A1%8Clint"><span class="nav-number">3.2.</span> <span class="nav-text">推荐使用gradle命令运行lint</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%85%8D%E7%BD%AE"><span class="nav-number">3.3.</span> <span class="nav-text">配置</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#lint-xml%E9%85%8D%E7%BD%AE"><span class="nav-number">3.3.1.</span> <span class="nav-text">lint.xml配置</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Java%E4%BB%A3%E7%A0%81%E9%85%8D%E7%BD%AE"><span class="nav-number">3.3.2.</span> <span class="nav-text">Java代码配置</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#xml%E6%96%87%E4%BB%B6%E9%85%8D%E7%BD%AE"><span class="nav-number">3.3.3.</span> <span class="nav-text">xml文件配置</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#gradle%E9%85%8D%E7%BD%AE"><span class="nav-number">3.3.4.</span> <span class="nav-text">gradle配置</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%87%AA%E5%AE%9A%E4%B9%89Lint%E6%B5%81%E7%A8%8B"><span class="nav-number">4.</span> <span class="nav-text">自定义Lint流程</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E8%87%AA%E5%AE%9A%E4%B9%89lint%E8%A7%84%E5%88%99"><span class="nav-number">4.0.1.</span> <span class="nav-text">自定义lint规则</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%BA%94%E7%94%A8lint%E8%A7%84%E5%88%99"><span class="nav-number">4.1.</span> <span class="nav-text">应用lint规则</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%BC%96%E5%86%99lint%E8%A7%84%E5%88%99"><span class="nav-number">5.</span> <span class="nav-text">编写lint规则</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%B8%B8%E7%94%A8api%E5%A6%82%E4%B8%8B"><span class="nav-number">5.1.</span> <span class="nav-text">常用api如下</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E4%BE%8B-%E6%A3%80%E6%9F%A5%E6%8E%A7%E4%BB%B6id%E5%91%BD%E5%90%8D%E5%89%8D%E7%BC%80%EF%BC%8C%E5%A6%82ImageView%E4%BB%A5iv-%E5%BC%80%E5%A4%B4%EF%BC%8CButton%E4%BB%A5btn%E5%BC%80%E5%A4%B4"><span class="nav-number">5.1.1.</span> <span class="nav-text">例:检查控件id命名前缀，如ImageView以iv_开头，Button以btn开头</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%90%8D%E8%AF%8D%E8%A7%A3%E9%87%8A"><span class="nav-number">5.2.</span> <span class="nav-text">名词解释</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%A1%A5%E5%85%85"><span class="nav-number">6.</span> <span class="nav-text">补充</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%8F%82%E8%80%83%E6%96%87%E7%AB%A0"><span class="nav-number">7.</span> <span class="nav-text">参考文章</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="丘山月夜"
      src="/images/avatar.png">
  <p class="site-author-name" itemprop="name">丘山月夜</p>
  <div class="site-description" itemprop="description">君は空を見てるか,<br>風の音を聞いてるか</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">60</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">14</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">21</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">丘山月夜</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://mist.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Mist</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
